<template>
	<div>
		<!--面包屑，导航区域-->
		<el-breadcrumb separator="/">
			<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item>权限管理</el-breadcrumb-item>
			<el-breadcrumb-item>权限列表</el-breadcrumb-item>
		</el-breadcrumb>
		<!--主体数据区域-->
		<el-card>
			<el-table :data="rightsList" style="width: 100%" :stripe="true">
				<el-table-column width="180" type="index" label="#"></el-table-column>
				<el-table-column prop="authName" label="权限名称" width="200"></el-table-column>
				<el-table-column prop="path" label="权限路径" ></el-table-column>
				<el-table-column prop="level" label="权限等级">
					<!--想要使用数据必须使用插槽-->
					<template slot-scope="scope">
						<el-tag v-if="scope.row.level == '0'" type="success">一级权限</el-tag>
						<el-tag v-else-if="scope.row.level == '1'" type="info">二级权限</el-tag>
						<el-tag v-else type="danger">三级权限</el-tag>
					</template>
				</el-table-column>
			</el-table>
		</el-card>
	</div>
</template>

<script type="text/javascript">
	export default {
		data() {
			return {
				rightsList: []
			}
		},
		//当页面加载完毕之后进行数据请求
		created() {
			this.getRightsList();
		},
		methods: {
			async getRightsList() {
				const {
					data: res
				} = await this.$http.get('rights/list');
				if (res.meta.status != 200) {
					this.$message.error('获取权限列表失败');
				}
				this.rightsList = res.data;
				console.log(this.rightsList)
			}
		}
	}
</script>

<style scoped="scoped">
	.el-card {
		margin-top: 7px;
	}
</style>
